use crate::config::AppConfig;
use crate::repositories::{
    minio_client, 
    PgDao,
    connect_pg
};

#[derive(Clone)]
pub struct AppState {
    pub pg_dao: PgDao,
    pub minio_state: minio_client::MinioClientState,
    pub app_config: AppConfig,
}

pub async  fn get_app_state() -> AppState {
    let app_config = AppConfig::load().await.unwrap();
    let pg_dao = connect_pg(&app_config).await.expect("Failed to connect to database");
    let minio_state = minio_client::get_minio_client(&app_config).await;
    AppState {
        pg_dao,
        minio_state: minio_state,
        app_config: app_config,
    }
}